package com.tengju.data.infrastructure.repository.clickhouse.convert;

import com.google.common.collect.Lists;
import com.tengju.data.domain.model.clickhouse.star.DwdStarChangeRecord;
import com.tengju.data.domain.model.user.UserIdCode;
import com.tengju.data.domain.shared.DateUtil;
import com.tengju.data.infrastructure.persistence.mybatis.dataobject.DwdStarChangeRecordDO;

import java.util.List;

public class DwdStarChangeRecordAllConvert {

    public static List<DwdStarChangeRecord> toModel(List<DwdStarChangeRecordDO> dwdStarChangeRecordDOS) {

        List<DwdStarChangeRecord> dwdStarChangeRecords = Lists.newArrayList();
        for (DwdStarChangeRecordDO dwdStarChangeRecordDO : dwdStarChangeRecordDOS) {
            if (dwdStarChangeRecordDO == null) {
                continue;
            }
            DwdStarChangeRecord dwdStarChangeRecord = new DwdStarChangeRecord(
                    new UserIdCode(dwdStarChangeRecordDO.getIdCode()),
                    dwdStarChangeRecordDO.getBeforeStarLevel(),
                    dwdStarChangeRecordDO.getAfterStarLevel(),
                    DateUtil.dateToLocalDateTime(dwdStarChangeRecordDO.getUpgradingTime()));
            dwdStarChangeRecords.add(dwdStarChangeRecord);
        }

        return dwdStarChangeRecords;
    }

}
